<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link type="text/css" href="../../css/system.css" rel="stylesheet"/>
<link type="text/css" href="../../js/jDialog/jDialog.css" rel="stylesheet" >
<script type="text/javascript" src="../../js/jDialog/jquery.dialog.js"></script>
<script type="text/javascript" src="../../js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../js/ajaxfileupload.js"></script>
<title>企业管理</title>
<script type="text/javascript">
 var companyId=0;
var companyObj = null;
$(document).ready(function() {
	$.ajax({
		type : 'post',
		dataType : 'text',
		async: false,
		url : '../../company/getCompanySession.action',
		success : function(msg) {
			 if (msg != 0 && msg != null) {
				 companyObj = JSON.parse(msg);
				 companyId = companyObj[0].companyId;
				 $("#headPhoto").attr("src",companyObj[0].companyLogo); 
				 $("#nickname").html(companyObj[0].companyLoginName);
			}	
		}
	});
    $("#manaInfo")[0].contentWindow.companyObj=companyObj;
	$("#uPwd")[0].contentWindow.companyObj=companyObj;
	$("#uCheck")[0].contentWindow.companyObj=companyObj;
	$("#cPers")[0].contentWindow.companyObj=companyObj;
	$("#rInfo")[0].contentWindow.companyObj=companyObj;//给Iframe传值 */
});
function reloadPage(){
	
	 $.chanIframe(1);
	 alert("good");
}
$.logout = function(){
	var dialog = jDialog.confirm('您确定要退出系统?',{
		handler : function(button,dialog) {
			$.ajax({
				type : 'post',
				dataType : 'text',
				async: false,
				url : '../../company/logoutCheck.action',
				success : function(msg) {
					window.location.href = "../../company_login.html";
				},
				error : function(msg) {
					window.location.href = "../../company_login.html";
				}
			});
			dialog.close();
		}
	},{
		handler : function(button,dialog) {
			dialog.close();
		}
	});
}
$.chanIframe = function(th){
	var idd = th;
	if(idd == 1){
		$("#menu1").css('background','#C0C0C0');
		$("#menu2").css('background','#66B3FF');
		$("#menu3").css('background','#66B3FF');
		$("#menu4").css('background','#66B3FF');
		$("#menu5").css('background','#66B3FF');
		$("#cPers").css('display', 'none');
		$("#uCheck").css('display', 'none');
		$("#manaInfo").css('display', 'block');
		$("#uPwd").css('display', 'none');
		$("#rInfo").css('display', 'none');
	}
	if(idd == 2){
		$("#menu2").css('background','#C0C0C0');
		$("#menu3").css('background','#66B3FF');
		$("#menu1").css('background','#66B3FF');
		$("#menu4").css('background','#66B3FF');
		$("#menu5").css('background','#66B3FF');
		$("#cPers").css('display', 'none');
		$("#uCheck").css('display', 'block');
		$("#manaInfo").css('display', 'none');
		$("#uPwd").css('display', 'none');
		$("#rInfo").css('display', 'none');
	}
	if(idd == 3){
		$("#menu3").css('background','#C0C0C0');
		$("#menu2").css('background','#66B3FF');
		$("#menu1").css('background','#66B3FF');
		$("#menu4").css('background','#66B3FF');
		$("#menu5").css('background','#66B3FF');
		$("#cPers").css('display', 'none');
		$("#uCheck").css('display', 'none');
		$("#manaInfo").css('display', 'none');
		$("#uPwd").css('display', 'block');
		$("#rInfo").css('display', 'none');
	}
	if(idd == 4){
		$("#menu4").css('background','#C0C0C0');
		$("#menu2").css('background','#66B3FF');
		$("#menu1").css('background','#66B3FF');
		$("#menu3").css('background','#66B3FF');
		$("#menu5").css('background','#66B3FF');
		$("#cPers").css('display', 'none');
		$("#uCheck").css('display', 'none');
		$("#manaInfo").css('display', 'none');
		$("#uPwd").css('display', 'none');
		$("#rInfo").css('display', 'block');
	}
	if(idd == 5){
		$("#menu4").css('background','#66B3FF');
		$("#menu2").css('background','#66B3FF');
		$("#menu1").css('background','#66B3FF');
		$("#menu3").css('background','#66B3FF');
		$("#menu5").css('background','#C0C0C0');
		$("#cPers").css('display', 'block');
		$("#uCheck").css('display', 'none');
		$("#manaInfo").css('display', 'none');
		$("#uPwd").css('display', 'none');
		$("#rInfo").css('display', 'none');
	}
}

$.uploadLogoPhoto = function(){
	var dialog = jDialog.confirm("<span style='font-weight:bold;font-size:15px;'>上传公司Logo</span><br\><input type='file' id='logoupload' onchange='$.checkFileType(this)' name='file'/>",{
		handler : function(button,dialog) {
			$.uploadCompanyLogo();
			dialog.close();
		}
	},{
		handler : function(button,dialog) {
			dialog.close();
		}
	});
}
$.uploadCompanyLogo = function() {
	if (typeof ($("#logoupload").val()) != 'undefined'
			&& $("#logoupload").val() != '') {
		$.ajaxFileUpload({
			url : '../../uploadf/uploadHeadPhoto.action', //用于文件上传的服务器端请求地址
			secureuri : false, //是否需要安全协议，一般设置为false
			fileElementId : 'logoupload', //文件上传域的ID
			dataType : 'HTML', //返回值类型 一般设置为json
			success : function(data, status) //服务器成功响应处理函数
			{
				$.ajax({
					type : 'post',
					dataType : 'text',
					async: false,
					url : '../../company/updateCompanyLogo.action',
					data:{
						"companyDTO.companyId":companyId,
						"companyDTO.companyLogo":data
					},
					success : function(msg) {
						$("#headPhoto").attr("src",data);
					},
					error : function(msg) {
						
					}
				});
			},
			error : function(data, status, e)//服务器响应失败处理函数
			{
				alert("上传失败");
			}
		})
	} else {
		alert("请先选择图片！");
	}
}
//判断上传文件的类型
$.checkFileType = function(obj) {
	var extend = obj.value.substring(obj.value.lastIndexOf(".") + 1);
	if (!(extend == "jpg" || extend == "JPG" || extend == "png"
			|| extend == "PNG" || extend == "jpeg" || extend == "JPEG"
			|| extend == "gif" || extend == "GIF" || extend == "bmp" || extend == "BMP")) {
		alert("请上传图片类型的文件!");
		var nf = obj.cloneNode(true);
		nf.value = '';
		obj.parentNode.replaceChild(nf, obj);
		return false;
	}
	return true;
}
</script>
</head>
<body>
<div style="position:relative;">
<div id="hidDiv">
<a onclick="$.logout()">退出登录</a>
</div>
<div id="topDiv">
<div class="logo"><img src="../../images/earth-globe.png"/></div>
<div class="logo1">招聘网</div>
<div class="topLink">
<img id="headPhoto" style="cursor:pointer;" onclick="$.uploadLogoPhoto()"/><span id="nickname"></span>
</div>
</div>
<div id="leftMenu">
<div class="menuDiv" id="menu1" onclick="$.chanIframe(1)"><img src="../../images/forjob.png"/>求职信息</div>
<div class="menuDiv" id="menu2" onclick="$.chanIframe(2)"><img src="../../images/cominfo.png"/>企业信息</div>
<div class="menuDiv" id="menu5" onclick="$.chanIframe(5)"><img src="../../images/resumeInfos.png"/>简历信息</div>
<div class="menuDiv" id="menu4" onclick="$.chanIframe(4)"><img src="../../images/prjob.png"/>招聘信息</div>
<div class="menuDiv" id="menu3" onclick="$.chanIframe(3)"><img src="../../images/chapwd.png"/>修改密码</div>
</div>
<div id="rightPage">
 <iframe  src="checkResume.html" name="manaInfo" id="manaInfo" width="100%" height="553px" > </iframe>
 <iframe style="display:none" src="companyInfo.html" name="uCheck" id="uCheck" width="100%" height="553px" > </iframe>
 <iframe style="display:none" src="upCompanyPwd.html" name="uPwd" id="uPwd" width="100%" height="553px" > </iframe>
 <iframe style="display:none" src="recruitmentInfo.html" name="rInfo" id="rInfo" width="100%" height="553px" > </iframe>
  <iframe style="display:none" src="checkPerson.html" name="cPers" id="cPers" width="100%" height="553px" > </iframe>
</div>
</div>
</body>
</html>